/**
 * Created by pankajmishra on 20/12/14.
 */
define(['jquery','mustache'], function($, Mustache){
    return function(item){

        item['commentCount'] = function(){
            return this.comments?this.comments.length:0;
        }
        var template = require('module/template/homeTemplate');
        var discussionhtml = $(Mustache.to_html(template['discussion-item'], item));

        discussionhtml.find('.js_detail').once('click', function(){
           var updateId = $(this).data('id');
            require(['module/discussion/detail'], function(detail){
                detail(updateId);
            });
        });

        return discussionhtml;

    };
});
